// Copyright 2017 The Kubernetes Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@use 'sass:map';
@use './variables' as *;
@use './mixins' as *;
@import '@angular/material/prebuilt-themes/deeppurple-amber.css';
@import './dark';
@import './light';

html,
body {
  font-family: $font-family-sans;
  height: 100%;
  margin: 0;
}

a {
  text-decoration: none;
}

button {
  &:not(:last-child) {
    margin-right: $baseline-grid;
  }
}

code {
  font-family: $font-family-monospace;
  padding: 0.25 * $baseline-grid;
}

* {
  &::-webkit-scrollbar {
    height: 0.5 * $baseline-grid;
    width: 0.5 * $baseline-grid;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: $baseline-grid;
  }
}

.mat-cell,
.mat-header-cell {
  @for $i from 30 through 150 {
    &.col-min-#{$i} {
      min-width: #{$i}#{'px'};
    }
  }

  &.col-stretch-s {
    flex: 1 1 (5 * $baseline-grid);
  }

  &.col-stretch-m {
    flex: 1 1 (10 * $baseline-grid);
  }

  &.col-stretch-l {
    flex: 1 1 (15 * $baseline-grid);
  }

  &.col-stretch-xl {
    flex: 1 1 (30 * $baseline-grid);
  }
}

.mat-progress-spinner {
  margin: 0 auto;
}

.mat-card {
  margin: $content-padding;

  .mat-card-title {
    margin-bottom: $baseline-grid;
  }

  .mat-card-content {
    padding-top: 2 * $baseline-grid;
  }
}

.mat-chip.mat-standard-chip {
  box-shadow: none !important;
  font-size: $body-font-size-base;
  font-weight: $regular-font-weight;
  height: fit-content;
  line-height: $body-font-size-base;
  min-height: unset;
  padding: ($baseline-grid * 0.75) ($baseline-grid * 1.25);
  transition: none !important;
  word-break: break-all !important;

  &:hover::after {
    opacity: 0 !important;
  }

  &:focus::after {
    opacity: 0 !important;
  }
}

.mat-header-row,
.mat-row {
  min-height: (5 * $baseline-grid) !important;
  padding: 0 (2 * $baseline-grid) !important;

  // Remove margin and padding on detail rows/cells
  &.kd-detail-row {
    min-height: 0 !important;
    padding: 0 !important;

    .mat-cell {
      margin: 0 !important;
    }
  }
}

.mat-header-cell {
  font-size: $body-font-size-base;
  padding: 0 ($baseline-grid * 0.5);

  &:first-child,
  &:last-child {
    padding: 0 !important;
  }
}

.mat-cell {
  margin: (0.5 * $baseline-grid) 0 !important;

  &:not(:first-child) {
    &:not(:last-child) {
      padding: 0 ($baseline-grid * 0.5);
    }
  }

  &:last-child {
    padding-right: 0 !important;
  }

  &:first-child {
    padding-left: 0 !important;
  }
}

.mat-column-statusicon {
  flex: 0 0 ($baseline-grid * 5);

  .mat-icon {
    cursor: default;
    font-size: 2.5 * $baseline-grid;
    margin-top: 0.66 * $baseline-grid;
  }
}

[class^='mat-column-action'],
[class*='mat-column-action'] {
  flex: 0 0 ($baseline-grid * 5) !important;
}

.mat-sort-header-arrow {
  align-self: center;
}

.mat-paginator-container,
.mat-paginator-range-actions {
  font-size: $body-font-size-base;
  min-height: 5 * $baseline-grid !important;
}

.mat-paginator-container {
  padding-right: 3 * $baseline-grid !important;
}

.mat-button-toggle-group {
  border-bottom: 0 !important;
  box-shadow: none !important;
}

router-outlet::after {
  padding: 0 !important;
}

////////////////////////////////////////////
// Custom classes used across application //
////////////////////////////////////////////

.kd-equivalent-block {
  border-radius: $baseline-grid * 0.25;
  font-size: $body-font-size-base;
  margin: (1.5 * $baseline-grid) 0;
  padding: $baseline-grid;

  mat-icon {
    @include kd-icon-size(3 * $baseline-grid);

    margin-right: $baseline-grid;
  }
}

.kd-dialog-text {
  font-family: $font-family-sans;
  padding-bottom: 0.5 * $baseline-grid;
  padding-top: 0;
}

.kd-toolbar-action {
  margin: 0 (0.75 * $baseline-grid) !important;
}

.kd-code-block {
  border-radius: $baseline-grid * 0.25;
  display: block;
  font-family: $font-family-monospace;
  font-size: $body-font-size-base;
  padding: $baseline-grid * 2;
  white-space: pre-wrap;
  width: 100%;
}

.kd-code-block-font {
  font-size: $body-font-size-base;
}

.kd-minimized-card {
  margin: 0 (2.5 * $baseline-grid);
  outline: none;

  &.mat-card {
    border-radius: 0;
  }
}

.kd-inline-property {
  display: inline-flex;
  margin-right: 3 * $baseline-grid;
}

.kd-card-group-header {
  font-family: $font-family-sans;
  font-size: $title-font-size-base;
  margin: (3 * $baseline-grid) 0 (2.5 * $baseline-grid) (4.5 * $baseline-grid);
}

.kd-card-top-radius {
  border-top-left-radius: 0.5 * $baseline-grid;
  border-top-right-radius: 0.5 * $baseline-grid;
}

.kd-bold {
  font-weight: $bold-font-weight;
}

.kd-h1 {
  font-size: 24px;
}

.kd-h3 {
  font-size: 16px;
}

.kd-card-padding {
  padding: 2.5 * $baseline-grid;
}

.kd-no-margin {
  margin: 0;
}

.kd-margin-bottom {
  margin-bottom: $baseline-grid;
}

.kd-margin-right {
  margin-right: $baseline-grid;
}

.kd-slider-value {
  font-size: $subhead-font-size-base-lg;
  text-align: right;
  width: 2 * $baseline-grid;
}

.mat-slider {
  margin-left: -$baseline-grid;
}

.kd-comma-separated-item {
  display: inline-block;

  &:not(:last-child) {
    &::after {
      content: ',';
    }
  }
}

.kd-pre-block {
  margin: 0;
  min-width: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.kd-loading-shade {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
  z-index: 1;
}

.kd-chips-show-button {
  cursor: pointer;
  font-size: $body-font-size-base;
  font-weight: $regular-font-weight;
  height: fit-content;
  line-height: $body-font-size-base;
  padding: ($baseline-grid * 0.75) ($baseline-grid * 1.75);
}

.kd-on-top {
  z-index: 100;
}

.kd-clickable {
  cursor: pointer !important;
}

.kd-ellipsised {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kd-no-bottom-border {
  border-bottom: 0 !important;
}

.kd-sparkline {
  height: 4 * $baseline-grid;
  vertical-align: -$baseline-grid * 0.5; // 20% below baseline, to flow with text
  width: 15 * $baseline-grid;
}

.kd-sparkline-value {
  font-weight: $bold-font-weight;
  position: absolute;
}

// This is a workaround to remove whitespace from code block element.
.kd-no-whitespace {
  font-size: 0;
}

.kd-hidden {
  display: none !important;
}

.mat-row:last-of-type {
  border-bottom: 0;
}

// Override Arial font type
.nvtooltip {
  font-family: Roboto, sans-serif;
}

.kd-secret-detail-text {
  .mat-form-field-wrapper {
    padding-bottom: $baseline-grid;
  }

  .mat-form-field-infix {
    padding-top: 2px;
  }

  textarea {
    padding: (2 * $baseline-grid) (2 * $baseline-grid) 0 !important;
  }
}

.kd-namespace-chip-list {
  overflow-x: hidden;

  &:focus {
    outline: none;
  }

  .mat-chip-list-wrapper {
    flex-wrap: nowrap;
    overflow-x: hidden;
  }
}

.mat-list {
  margin-top: $baseline-grid;

  &.mat-list-base {
    padding-top: 0;
  }
}

kd-logs {
  .mat-form-field {
    max-width: 22 * $baseline-grid;
    width: auto;

    .mat-form-field-underline {
      margin-top: 0.25 * $baseline-grid;
      position: initial;
    }

    .mat-form-field-wrapper {
      padding-bottom: 0;
    }

    .mat-form-field-infix {
      border-top: 0;
      padding: 0;
      width: auto;
    }

    .mat-select-trigger {
      align-items: center;
      display: flex;
    }

    .mat-select-value {
      display: inline-flex;
      max-width: 100%;
      padding-right: $baseline-grid;
    }
  }
}

.mat-menu-panel {
  &.kd-user-panel {
    min-width: 15 * $baseline-grid;
  }
}
